package JavaDesign.report_1.t_2;

/**
 * @author zouran
 * createDate：2023/9/20  18:25
 */
public class Triangle extends Geometry {
    double a, b, c;

    public Triangle(double a, double b, double c) {
        this.a = a;
        this.b = b;
        this.c = c;
    }

    @Override
    public double getArea() {
        double s, p;

        if (a + b > c && b + c > a && a + c > b)//判断是否可以形成三角形

        {

            p = (a + b + c) / 2;//求半周长
            s = Math.sqrt(p * (p - a) * (p - b) * (p - c));//求面积
            return s;

        } else {
            System.out.print("该三角形不合法！！");
            return 0;
        }
    }

}
